package com.apes.fn.server.pickUpCar.repository;

import com.apes.fn.server.pickUpCar.model.PickUpCar;
import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.frame.model.Dept;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

/**
 * @Classname PickUpCarRepository
 * @Description 接车单
 * @Date 2020/1/14 16:59
 * @Created by Administrator
 */
public interface PickUpCarRepository extends CustomRepository<PickUpCar, String> {

    List<PickUpCar> findByLicenseNumberAndDeptAndState(String licenseNumber, Dept dept, String state);
    List<PickUpCar> findByDeptAndState(Dept dept, String state);
    List<PickUpCar> findByLicenseNumberAndPickCarTypeAndState(String licenseNumber, Enumeration pickCarType, String state);

    List<PickUpCar> findByDeptIdAndFnCustomerExpandIdOrderByCreateDateDesc(String deptId,String fnCustomerExpandId);

    @Query("select a " +
            "from PickUpCar a where a.lastUpdatedStamp > :times or (a.id > :id and a.lastUpdatedStamp = :times)  " +
            " order by a.lastUpdatedStamp, a.id asc ")
    List<PickUpCar> queryPickUpCar(@Param("times") Date times, @Param("id") String id, Pageable pageable);


    List<PickUpCar> findAllBySource(String Source);


}
